package org.ajax.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;

/**
 * @author CSY
 * @date 2024-11-19
 */
@WebServlet("/login.do")
public class LoginServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("userName");
        String pwd = req.getParameter("pwd");
        String msg = "错误的账号或密码";
        PrintWriter out = resp.getWriter();
//        String info =
        if(name.equals("admin") && pwd.equals("123")) {
            msg = "登录成功";
        }
        out.write(msg);
        out.flush();
        out.close();
    }
}
